﻿Imports System.Windows.Forms

Public Class FormMain


    Private Sub btnSource_Click(sender As Object, e As EventArgs) Handles btnSource.Click
        Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog

        ' Descriptive text displayed above the tree view control in the dialog box
        MyFolderBrowser.Description = "Select the Folder"

        ' Sets the root folder where the browsing starts from
        'MyFolderBrowser.RootFolder = Environment.SpecialFolder.MyDocuments

        ' Do not show the button for new folder
        MyFolderBrowser.ShowNewFolderButton = False

        Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()

        If dlgResult = Windows.Forms.DialogResult.OK Then
            txtSource.Text = MyFolderBrowser.SelectedPath
        End If

    End Sub

    Private Sub btnDestination_Click(sender As Object, e As EventArgs) Handles btnDestination.Click
        Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog

        ' Descriptive text displayed above the tree view control in the dialog box
        MyFolderBrowser.Description = "Select the Folder"

        ' Sets the root folder where the browsing starts from
        'MyFolderBrowser.RootFolder = Environment.SpecialFolder.MyDocuments

        ' Do not show the button for new folder
        MyFolderBrowser.ShowNewFolderButton = False

        Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()

        If dlgResult = Windows.Forms.DialogResult.OK Then
            txtDestination.Text = MyFolderBrowser.SelectedPath
        End If

    End Sub

    Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
        If txtDestination.Text.Length > 0 And txtSource.Text.Length > 0 Then
            lblStatus.Text = "Conversion Started:"
            btnConvert.Enabled = False

            Converter.ConvertFile(txtSource.Text, txtDestination.Text, Me.cbCreateNavigation.Checked)
            btnConvert.Enabled = True
        Else
            MsgBox("Source and Destination Folders must have a value")
        End If

    End Sub

    Private Sub FormMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lblStatus.Text = ""
    End Sub
End Class